package com.yerbamateprimer.advice.impl;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.google.common.base.Preconditions;
import com.yerbamateprimer.advice.SingleReceptorAdvice;
import com.yerbamateprimer.model.User;

/**
 * This class models an advice
 * to let the primer know that  
 * the mate was drunk.
 * 
 * @author Matias Liwski
 * @version 1.0
 */
public class MateDrunkAdvice implements SingleReceptorAdvice {
	private static final long serialVersionUID = 6028133581636447718L;
	private User receptor;
	private User drinker;

	/**
	 * @param receptor The receptor of the advice.
	 * @param drinker The mate drinker.
	 */
	public MateDrunkAdvice(User receptor, User drinker) {
		setAdviceReceptor(receptor);
		setDrinker(drinker);
	}

	/* (non-Javadoc)
	 * @see com.yerbamateprimer.advice.SingleReceptorAdvice#setReceptor(com.yerbamateprimer.model.User)
	 */
	@Override
	public void setAdviceReceptor(User adviceReceptor) {
		Preconditions.checkArgument(adviceReceptor != null, "This advice need a receptor.");
		this.receptor = adviceReceptor;
	}

	/* (non-Javadoc)
	 * @see com.yerbamateprimer.advice.SingleReceptorAdvice#getReceptor()
	 */
	@Override
	public User getAdviceReceptor() {
		return this.receptor;
	}

	/**
	 * @param drinker The mate drinker to set.
	 */
	public void setDrinker(User drinker) {
		Preconditions.checkArgument(drinker != null, "This advice need to know how drunk the mate.");
		this.drinker = drinker;
	}

	/**
	 * @return The mate drinker.
	 */
	public User getDrinker() {
		return drinker;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE, false, false);
	}
}